package com.cloud.phone.view;

import android.content.Context;
import android.os.Build;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.cloud.phone.R;
import com.cloud.phone.bean.AppInfo;

import java.util.List;

/**
 * @auth: njb
 * @date: 2024/5/20 14:13
 * @desc: 描述
 */
public class IpInfoAdapter extends RecyclerView.Adapter<IpInfoAdapter.IpInfoViewHolder> {
    private List<AppInfo> mList;
    private Context mContext;
    private LayoutInflater inflater;

    public IpInfoAdapter(Context context, List<AppInfo> data) {
        this.mContext = context;
        this.mList = data;
        inflater = LayoutInflater.from(mContext);
    }

    @NonNull
    @Override
    public IpInfoViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        View view = inflater.inflate(R.layout.item_ipinfo, viewGroup, false);
        return new IpInfoViewHolder(view);
    }

    @Override
    public void onBindViewHolder(IpInfoViewHolder holder, final int position) {
            holder.textView.setText(mList.get(position).getApkName());
    }

    @Override
    public int getItemCount() {
        return mList != null && !mList.isEmpty() ? mList.size() : 0;
    }

    public class IpInfoViewHolder extends RecyclerView.ViewHolder {
        private TextView textView;

        public IpInfoViewHolder(@NonNull View itemView) {
            super(itemView);
            textView = itemView.findViewById(R.id.tv_apk_name);
        }
    }
}
